package com.learn.service;

import com.learn.mapper.UserMapper;
import com.learn.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

//    @Autowired
    private OrderService orderService;

//    @Autowired
//    public UserService(OrderService orderService) {
//        this.orderService = orderService;
//    }

    @Autowired
    public void setOrderService(OrderService orderService) {
        this.orderService = orderService;
    }

    public User findByUsername(String username) {
        orderService.test();
        return userMapper.find(username);
    }


    public List<User> listUser() {
        System.out.println("---测试---");
        return userMapper.queryAll();
    }


    public int insertUser(User user) {
        return userMapper.insert(user);
    }


    public int updateUser(User user) {
        return userMapper.update(user);
    }


    public int delete(int id) {
        return userMapper.delete(id);
    }
}
